package com.hibikiluler.javalearning.controller;

import com.hibikiluler.javalearning.entity.SysAdmins;
import com.hibikiluler.javalearning.entity.SysMenus;
import com.hibikiluler.javalearning.service.SysAdminService;
import com.hibikiluler.javalearning.service.SysMenusService;
import com.hibikiluler.javalearning.util.Queryinfo;
import com.hibikiluler.javalearning.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 权限数据控制层
 */
@Slf4j
@RestController
@Api(tags = "菜单数据")
@RequestMapping("/menus")
public class SysMenusController {

    @Autowired
    private SysMenusService menusService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public Result findPage(@RequestBody Queryinfo queryinfo) {
        return menusService.findPage(queryinfo);
    }

    @ApiOperation(value = "添加菜单")
    @PostMapping("/insert")
    public Result insert(@RequestBody SysMenus menus) {
        return menusService.insert(menus);
    }

    @ApiOperation(value = "删除菜单")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id) {
        return menusService.delete(id);
    }

    @ApiOperation(value = "修改菜单")
    @PutMapping("/update")
    public Result update(@RequestBody SysMenus menus) {
        return menusService.update(menus);
    }

    @ApiOperation(value = "查询所有的父级菜单")
    @GetMapping("/findParent")
    public Result findParent() {
//        String str = menusService.findParent().toString();
//        log.info(str);
        return menusService.findParent();
    }
}
